//
//  JMCPICell.m
//  NewiOSProject
//
//  Created by apple on 2023/9/16.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import "JMOrderCell.h"
#import "JMBankAccountController.h"
@implementation JMOrderCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.contentView.layoutMargins = UIEdgeInsetsMake(6, 15, 6, 15);
        self.backgroundColor = Hex_Str_COLOR(@"#F6F9FE");
        [self setUI];
    }
    return self;
}
-(void)setUI{
    self.contV = [[UIView alloc]initWithFrame:(CGRectMake(0, 8, kAppW(), 116))];
    [self.contentView addSubview:self.contV];
    self.contV.backgroundColor = WhiteColor();
    
    _iconImgV = [[UIImageView alloc]initWithFrame:CGRectMake(24, 12, 24, 24)];
    [self.contV addSubview:_iconImgV];
    
    _nameLab = [JMControl createLabelWithFrame:(CGRectMake(_iconImgV.right+5, _iconImgV.top, 200, 24)) Font:fontWithWeight(12, UIFontWeightMedium) Text:@"Go Tunai" color:Hex_Str_COLOR(@"#323848")];
    [self.contV addSubview:_nameLab];
    
    _rightImgV = [[UIImageView alloc]initWithFrame:(CGRectMake(kAppW()-48, 12, 24, 24))];
    _rightImgV.image = ImageNamed(@"ICON／you-xiao");
    [self.contV addSubview:self.rightImgV];
    
    _stateLab = [JMControl createLabelWithFrame:(CGRectMake(_rightImgV.left-kAppW()/2, 0, kAppW()/2, FontH(14))) Font:Font(14) Text:@"" color:Hex_Str_COLOR(@"#3C57F8") textAlignment:2 numberOfLine:0];
    [self.contV addSubview:_stateLab];
    _stateLab.centerY = _rightImgV.centerY - 2;
    
   
    _priceTitleLab = [JMControl createLabelWithFrame:(CGRectMake(_iconImgV.left, _iconImgV.bottom+12, kAppW()/2, 20)) Font:Font(14) Text:@"Importe del préstamo" color:Hex_Str_COLOR(@"#9B9B9B")];
    [self.contV addSubview:_priceTitleLab];
    
    _priceLab = [JMControl createLabelWithFrame:(CGRectMake(_priceTitleLab.left, _priceTitleLab.bottom+8, kAppW()/2, 28)) Font:mediumFont(20) Text:@"$10,000" color:Text_COLOR_LEVEL1()];
    [self.contV addSubview:_priceLab];
    
    
    _timeTiTleLab = [JMControl createLabelWithFrame:(CGRectMake(kAppW()/2-24, _priceTitleLab.top, kAppW()/2, FontH(12))) Font:Font(14) Text:@"Fecha de vencimiento " color:Hex_Str_COLOR(@"#9B9B9B")];
    [self.contV addSubview:_timeTiTleLab];
    
    _timeLab = [JMControl createLabelWithFrame:(CGRectMake(_timeTiTleLab.left, _priceLab.top, kAppW()/2, 21)) Font:mediumFont(15) Text:@"03-04-2022" color:Text_COLOR_LEVEL1()];
    [self.contV addSubview:_timeLab];
    _timeLab.bottom = _priceLab.bottom;
   
    
    _lineV = [JMControl addHorLineWithSpace:_iconImgV.left top:_priceLab.bottom+12 height:1 bgColor:mainSepartorColor() toView:self.contV];
    _lineV.width = kAppW()-48;
    
    _warning = [[UIImageView alloc]initWithFrame:(CGRectMake(26, _lineV.bottom+10, 16, 16))];
    _warning.image = ImageNamed(@"ICON／bagnz");
    [self.contV addSubview:_warning];
    
    
    _warningLab = [JMControl createAutoHeightLabelWithOrgin:(CGPointMake(_warning.right+4, _warning.top-3)) andWidth:kAppW()-72 Font:Font(12) Text:@"Por favor, compruebe su cuenta bancaria, puede continuar aplicando productos después de la modificación" color:Hex_Str_COLOR(@"#FF5134")];
    [self.contV addSubview:_warningLab];
    
    _modifyBtn = [[JMLoadingButton alloc]initWithFrame:(CGRectMake(16,_warningLab.bottom+16 , self.contentView.width-32, 46)) title:@" Ir a modificar" font:Font(16) titleLabelColor:Hex_Str_COLOR(@"#FEFFCC") backgoundColor:Text_COLOR_LEVEL1() action:@selector(modifyBtnClick) target:self];
    [self.contV addSubview:_modifyBtn];
    _modifyBtn.cornerRadius = 12;
    
}
-(void)modifyBtnClick{
    JMBankAccountController *vc = JMBankAccountController.new;
    [self.viewController.navigationController pushViewController:vc animated:YES];
}

-(void)setModel:(JMOrderModel *)model{
    _model = model;
    [_iconImgV sd_setImageWithURL:URLImageWithUrlStr(model.slogan) placeholderImage:nil];
    _nameLab.text = model.productName;
    _stateLab.text = model.statusString;
    _timeTiTleLab.text = model.timeLabeString;
    _timeLab.text = model.timeString;
    _priceLab.text = model.priceString;
    _stateLab.textColor = Hex_Str_COLOR(model.statusTextColor);
    
    _warningLab.text = model.warningString;
    _warningLab.width = model.warnimgHidden?kAppW()-48:kAppW()-72;
    _warningLab.height = CalculateLabelHeightWithLab(_warningLab);
    _warningLab.top = model.modifyBtnHidden?_lineV.bottom+8:_modifyBtn.bottom+8;
    _warningLab.left = model.warnimgHidden?24:48;
    
    _warning.top = _warningLab.top;
    self.contV.height = model.warningLabHidden?116:_warningLab.bottom+12;
    model.rowHeight = self.contV.bottom+8;
   
    _rightImgV.hidden = model.rightArrowHidden;
    _lineV.hidden = model.warningLabHidden;
    _warning.hidden = model.warnimgHidden;
    _modifyBtn.hidden = model.modifyBtnHidden;
    _warningLab.hidden = model.warningLabHidden;
}

@end
